#coding:utf-8

from PySide6.QtWidgets import QApplication,QWidget,QMainWindow,QVBoxLayout,QPushButton
from ModuleManager import ModuleManager
class MainPanel(QMainWindow):
    
    def __init__(self):
        super().__init__()
        
        widget = QWidget()
        layout = QVBoxLayout()
        layout.setContentsMargins(100,100,100,100)
        loadButton = QPushButton('加载所有模块')
        loadButton.clicked.connect(self.loadModules)
        layout.addWidget(loadButton)

        removeButton = QPushButton('删除所有模块')
        removeButton.clicked.connect(self.removeModules)
        layout.addWidget(removeButton)
        widget.setLayout(layout)
        self.testWidget = QWidget()
        layout.addWidget(self.testWidget)
        self.setCentralWidget(widget)
        self.setGeometry(100,100,600,400)
        

        self.manager = ModuleManager(self)
    
    def getTestWidget(self):
        '''
        返回一个用于测试的widget
        '''
        return self.testWidget

    def loadModules(self):
        '''加载所有的模块'''
        self.manager.loadAllModules()

    def removeModules(self):
        '''删除所有的模块'''
        self.manager.removeAllModules()

if __name__ == "__main__":
    app = QApplication()
    panel = MainPanel()
    panel.show()
    app.exec()

    
